package a11;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * @author ANDyT
 *
 */
public class FileOSHandler {
	
	private File srcFile;
	private File dstFile;
	
	public FileOSHandler() {
		 this.srcFile = new File("");
		 this.dstFile = new File("");
	}
	
	public void saveFile(File src, File dst) throws IOException {
		FileChannel srcChannel = new FileInputStream(src).getChannel();
		FileChannel dstChannel = new FileOutputStream(dst).getChannel();
		try {
			srcChannel.transferTo(0, srcChannel.size(), dstChannel);
		} catch (IOException e) {
			throw e;
		} finally {
			if (srcChannel != null)
				srcChannel.close();
			if (dstChannel != null)
				dstChannel.close();
		}
	}

	/**
	 * @param srcFile the srcFile to set
	 */
	public void setSrcFile(File srcFile) {
		this.srcFile = srcFile;
	}

	/**
	 * @return the srcFile
	 */
	public File getSrcFile() {
		return srcFile;
	}

	/**
	 * @param dstFile the dstFile to set
	 */
	public void setDstFile(File dstFile) {
		this.dstFile = dstFile;
	}

	/**
	 * @return the dstFile
	 */
	public File getDstFile() {
		return dstFile;
	}

}
